﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace RestSharpDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            #region 自测
            ///*Get请求*/
            //var client = new RestClient("http://localhost:33510");
            //var request = new RestRequest("/webservice/App_BasicInformation/GetCityCommunity", Method.GET);
            //IRestResponse<Info<Community>> response = client.Execute<Info<Community>>(request);//.Execute(request);
            //string str = response.Content;

            /*Post请求*/
            //var client = new RestClient("http://localhost:33510");
            //var request = new RestRequest("/webservice/App_BasicInformation/GetCompanyAllList", Method.POST);
            //request.RequestFormat = DataFormat.Json;
            //request.AddBody(new
            //{
            //    regionId = 0
            //});
            //IRestResponse<Info<Company>> response = client.Execute<Info<Company>>(request);
            //string str = response.Content; 
            #endregion

            #region 农历信息--Get
            var client = new RestClient("https://www.sojson.com/open/api/lunar/json.shtml");
            //client.AddDefaultHeader("ContentType","application/json");
            var request = new RestRequest("", Method.GET)
            {
                RequestFormat = DataFormat.Json
            };
            IRestResponse<CalenderModel<Calender>> response = client.Execute<CalenderModel<Calender>>(request);
            #endregion


            Console.ReadLine();
        }
    }

    #region TestEntity
    public class Info<T>
    {
        public List<T> Data { get; set; }
        public bool IsSuccess { get; set; }
        public string Message { get; set; }
    }
    public class Community
    {
        public string CommunityID { get; set; }
        public string CommunityName { get; set; }
    }
    public class Company
    {
        public string ComOrgID { get; set; }
        public string ComName { get; set; }
        public string ComShortName { get; set; }
        public string ComAddress { get; set; }
    } 
    #endregion

    #region Stock
    
    #endregion
}
